package com.gdougms.mapper;

import com.gdougms.entity.Field;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface FieldMapper {

    //获取所有场地
    @Select("select * from field where state != 0")
    List<Field> fieldList();

    //增加场地
    @Insert("insert into field(name,area,cost) values(#{name},#{area},#{cost})")
    int addField(String name,String area,BigDecimal cost);

    //根据id删除场地
    @Update("update field set state=0 where id=#{id}")
    int deleteFieldById(Integer id);

    //根据id修改场地信息
    int updateFieldStateById(String name, String area, BigDecimal cost,Integer id,Integer state);

    //获取表中有的所有area
    @Select("select DISTINCT area from field where state!=0")
    List<String> getAllArea();

    //获取表中所有的费用类型
    @Select("select DISTINCT cost from field where state!=0")
    List<BigDecimal> getAllCost();

    //获取area为xxx的场地所有信息
    @Select("select * from field where area=#{area} and state!=0")
    List<Field> getAllFieldByArea(String area);

    //获取cost为xxx的场地所有信息
    @Select("select * from field where cost=#{cost} and state!=0")
    List<Field> getAllFieldByCost(BigDecimal cost);

}
